<%-- 
    Document   : askQuestion
    Created on : 28-nov-2012, 18:05:14
    Author     : Marco
--%>
<%@page import="java.util.ArrayList"%>
<%@page import="beans.InhoudBean1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@page contentType="text/html" pageEncoding="windows-1252"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    </head>
    <body>
        <div class="flag-wrapper">

            <%
                HttpSession sessie2 = request.getSession();
                ArrayList<String> wrongUrls = new ArrayList();
                ArrayList<String> correctUrls = new ArrayList();
                if (sessie2.getAttribute("wrongUrls") == null) {
                    wrongUrls.add("/about");
                    correctUrls.add("/about.jsp");
                    wrongUrls.add("/admin_home");
                    correctUrls.add("/admin_home.jsp");
                    wrongUrls.add("/course_view");
                    correctUrls.add("/course_view.jsp");
                    wrongUrls.add("/leraar_home");
                    correctUrls.add("/leraar_home.jsp");
                    wrongUrls.add("/moduleList");
                    correctUrls.add("/moduleList.jsp");
                    wrongUrls.add("/student_home");
                    correctUrls.add("/student_home.jsp");
                    wrongUrls.add("/visitor_home");
                    correctUrls.add("/visitor_home.jsp");
                    wrongUrls.add("/manage_courses");
                    correctUrls.add("/manage_courses.jsp");
                    wrongUrls.add("/forgot_password");
                    correctUrls.add("/forgot_password.jsp");
                    

                    sessie2.setAttribute("wrongUrls", wrongUrls);
                    sessie2.setAttribute("correctUrls", correctUrls);
                } else {
                    wrongUrls = (ArrayList<String>) sessie2.getAttribute("wrongUrls");
                    correctUrls = (ArrayList<String>) sessie2.getAttribute("correctUrls");
                }
                if (sessie2.getAttribute("inhoud") == null) {
                    InhoudBean1 c = new InhoudBean1();
                    sessie2.setAttribute("inhoud", c);
                }
                sessie2.setAttribute("taal", "en");
                String address = request.getServletPath(), address2 = "";
                for (int i = 0; i < address.length() - 4; i++) {
                    address2 = address2 + address.charAt(i);
                }
                boolean found = false;
                int i = 0;
                do {
                    if (address2.equals(wrongUrls.get(i))) {
                        address2 = correctUrls.get(i);
                        found = true;
                    }
                    i++;
                } while (!found && i < wrongUrls.size());
                String queryString = request.getQueryString();
                if(address2.equals("/subscribe_confirmation")){
                    if(queryString.length() > 4){
                        address2 = "/combi_deals-confirm";
                    } else {
                        address2 = "/subscribe-confirm";
                    }
                }
                address2 = address2 + "?" + queryString;
                sessie2.setAttribute("address", address2);
            %>
            <c:choose>
                <c:when test="${inhoud.taal eq taal}">
                    <a href="changeLang?lang=nl"><img src="icons/dutch_flag.jpg" align="right"></a>
                    </c:when><c:otherwise>
                    <a href="changeLang?lang=en"><img src="icons/english_flag.jpg" align="right"></a>
                    </c:otherwise></c:choose>
        </div>
    </body>
</html>
